package com.heima.wemedia.controller.v1;

import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.SensitiveDto;
import com.heima.model.wemedia.pojos.WmSensitive;
import com.heima.wemedia.service.WmSensitiveService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@RequestMapping("/api/v1/sensitive")
public class WmSensitiveController {
    @Autowired
    private WmSensitiveService wmSensitiveService;


    /**
     * 分页条件查询敏感词
     *
     * @return
     */
    @PostMapping("/list")
    public ResponseResult listSensitive(@RequestBody SensitiveDto dto) {
        log.info("条件分页查询敏感词列表....");
        //调用service
        return wmSensitiveService.listAllSensitive(dto);
    }

    /**
     * 新增敏感词
     *
     * @param dto
     * @return
     */
    @PostMapping("/save")
    public ResponseResult saveSensitive(@RequestBody WmSensitive dto) {

        return wmSensitiveService.saveSensitive(dto);
    }


    /**
     * 修改敏感词
     *
     * @param dto
     * @return
     */
    @PostMapping("/update")
    public ResponseResult updateSensitive(@RequestBody WmSensitive dto) {
        //调用service
        return wmSensitiveService.updateSensitive(dto);
    }

    /**
     * 删除敏感词
     * @param id
     * @return
     */
    @DeleteMapping("/del/{id}")
    public ResponseResult delSensitive(@PathVariable("id")Integer id){
        return wmSensitiveService.delSensitive(id);
    }
}
